﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Schema;

namespace If_Else
{
    class Program
    {
        static void Main(string[] args)
        {//判断整除
            Console.Write("请输入一个整数：");
            string strNum = Console.ReadLine();
            int dot = strNum.IndexOf(".");//第一次出现小数点位置
            if (dot == -1)
            {
                int intNum = Convert.ToInt32(strNum);
                if (intNum % 2 == 0 && intNum % 3 == 0)
                {
                    Console.WriteLine("yes");
                }
                else
                {
                    Console.WriteLine("no");
                }
            }
            else
            {
                Console.WriteLine("输入错误，请重新输入");
            }
            //判断一个数是奇书还是偶数
            Console.Write("请输入一个正整数：");
            string Number1 = Console.ReadLine();
            int Number2 = Number1.IndexOf(".");
            if (Number2 == -1)
            {
                int Number3 = Convert.ToInt32(Number1);
                if (Number3 % 2 == 0)
                {
                    Console.WriteLine("为偶数");
                }
                else
                {
                    Console.WriteLine("为奇数");
                }
            }
            else
            {
                Console.WriteLine("输入错误，请重新输入");
            }
            //输入一个分数，小于60不合格，60~90合格，90~100优秀
            Console.Write("请输入一个分数：");
            double Number4 = double.Parse(Console.ReadLine());
            if (Number4 >= 0 && Number4 <= 100)
            {
                if (Number4 <= 60)
                {
                    Console.WriteLine("分数不合格");
                }
                else //也可以直接用else if 
                {
                    if (Number4 > 60 && Number4 <= 90)
                    {
                        Console.WriteLine("分数合格");
                    }
                    else
                    {
                        Console.WriteLine("分数优秀");
                    }
                }
            }
            else
            {
                Console.WriteLine("输入分数错误");
            }
            //do  while 
            int i = 0;
            do
            {
                Console.WriteLine(i);
                i++;//注意它的位置
            } while (i < 10);//输出0~9

            //for 
            for (int j = 0; j < 100; j++)
            {
                Console.WriteLine(j);
            }
            //break & continue
            for (int k = 0; k < 10; k++)
            {
                if (k == 5)
                {
                    continue;
                }
                if (k == 8)
                {
                    break;
                }
                Console.Write(k);
            }

            //foreach
            int[] array = { 1, 2, 3, 4, 5 };
            foreach (int item in array)//定义一个int类型数组
            {
                Console.WriteLine(item);//遍历数组的每一项之后循环自动终止
            }

            //输出1到100能够被3整除但不能被5整除的数，并且统计有多少个数。
            int countnum = 0;
            for (int m = 1; m <= 1000; m++)
            {
                if (m % 3 == 0 && m % 5 != 0)
                {
                    Console.WriteLine(m);
                    countnum = countnum + 1;
                }
            }
            Console.WriteLine("总数：{0}", countnum);

            //求输出1到6000之间，“用3除余2，5余3，7余2”以空格隔开，每行输出5个数
            int temp = 0;
            for (int a = 1; a <= 6000; a++)
            {
                if (a % 3 == 2 && a % 5 == 3 && a % 7 == 2)
                {
                    Console.Write(a);
                    Console.Write(" ");
                    string str1 = Convert.ToString(a);
                    int len1 = str1.Length;
                    //for (len1 = len1+1; len1 <= 4; len1++)//5-i.tostring().length，也可以有left和right
                    //{
                    //    Console.Write(" ");
                    //}
                    for (len1 = 4-len1;  len1<=4; len1++)
                    {
                        Console.Write(" ");
                    }
                    
                    temp++;
                    if (temp % 5 == 0)
                    {
                        Console.WriteLine("");
                    }
                }
            }
            Console.WriteLine("");
            Console.WriteLine("总数：{0}", temp);

            Console.ReadKey();
        }
    }
}
